package bma.common.netty.webserver.common;

import org.jboss.netty.handler.codec.http.HttpHeaders.Names;

import bma.common.langutil.ai.stack.AIStack;
import bma.common.netty.webserver.RequestContext;
import bma.common.netty.webserver.RequestProcessor;

public class RequestDispatcherHost extends RequestDispatcherMatch {

	public RequestDispatcherHost() {
		super();
	}

	public RequestDispatcherHost(RequestProcessor processor) {
		super(processor);
	}

	@Override
	public boolean dispatch(AIStack<Boolean> stack, RequestContext ctx)
			throws Exception {
		String host = ctx.getRequest().getHeader(Names.HOST);
		if (host == null)
			return false;
		if (!this.matcher.match(host)) {
			return false;
		}
		return dispatchOrProcess(stack, processor, ctx);
	}

}
